package com.samtech.spring.components;

import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.samtech.domain.EtAirport;
import com.samtech.primefaces.service.EtAirportService;







@Component("viewEtairport")
@Scope("request")
public class ViewEtairport implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3314320372094812499L;

	private EtAirport etAirport;
	
	private EtAirportService etAirportService;
	
	public ViewEtairport() {}
	
	@Autowired
	public ViewEtairport(EtAirportService etAirportService) {
		this.etAirportService = etAirportService;
	}
	
	
	public void onLoad() {
		String movieId = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("etairportId");
		etAirport = etAirportService.findById(movieId);
	}
	
	public EtAirport getEtAirport() {
		return etAirport;
	}

	public void setEtAirport(EtAirport et) {
		this.etAirport = et;
	}
	
	public String update() {
		etAirportService.update(etAirport);
		FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, "Movie is updated successfully", "OK");
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
		
		return null;
	}
	
	public String remove() {
		etAirportService.remove(etAirport);
		
		return "listMovies";
	}
}
